module.exports = function ($scope, $state, $resource, $modal, toaster, $stateParams) {

  
  $scope.bigCurrentPage = 1;      //当前页码
  $scope.itemsPerPage = 10; 
  $scope.searchform = {};

	$scope.loadlist = function(pageNo){
    var para = {
        'pageNo': pageNo, 
        'pageSize': $scope.itemsPerPage,
        'name': $scope.searchform.name,
        'title': $scope.searchform.title,
        'state': '9'
    };
		$resource('/api/as/csc/auditorder/orderlist', {}, {}).save(para, function(res){
			if (res.errcode === 0) {
        $scope.objs = res.data.results;
        $scope.bigTotalItems = res.data.totalRecord;
			} else {
				toaster.error({ title: '', body: '查询草稿事项失败'});
			}
		});
	}
  $scope.loadlist(1);
  
  $scope.getInfo = function(item){
      $state.go('app.itemInfo', {'item_id': item.item_id, 'cardno': item.cardno, 'flag': '1', 'code': item.code});
      // item.id = item.item_id;
      // var modalInstance = $modal.open({
      //   template: require('../views/itemInfo.html'),
      //   controller: 'itemInfo',
      //   size: 'lg',
      //   resolve: {
      //     'obj' : function(){
      //         return item;
      //     },
      //     'flag' : function(){
      //         return true;
      //     }
      //   }
      // });
      // modalInstance.result.then(function () {
      //   $scope.loadlist(1);
      // });
  }


	$scope.upload = function(obj){
    if (confirm('确认信息无误，提报此事项?')){
        $resource('/api/ac/csc/auditOrderService/setOrderApply', {}, {}).save({'code' : obj.code}, function(res){
          if (res.errcode === 0) {
            toaster.success({ title: '', body: '成功'});
            $scope.loadlist($scope.bigCurrentPage);
          } else {
            toaster.error({ title: '', body: '失败，请稍后再试'});
          }
        });
    }
  }

};